﻿namespace SuperModel.BehaviorModel
{
    using Castle.Core.Interceptor;

    /// <summary>
    /// The base class for a get action
    /// </summary>
    public abstract class BaseGetAction : IPropertyGetAction
    {
        /// <summary>
        /// Gets or sets the target property name
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// Execute the Invocation
        /// </summary>
        /// <param name="invocation">The invocation</param>
        /// <param name="propertyName">The property name</param>
        public void Execute(IInvocation invocation, string propertyName)
        {
            if (PropertyName == propertyName)
            {
                ExecuteInternal(invocation);
            }
        }

        /// <summary>
        /// The internal invocation execution
        /// </summary>
        /// <param name="invocation">The invocation</param>
        protected abstract void ExecuteInternal(IInvocation invocation);
    }
}